home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Sample.bin / SwingSetApplet.java < prev    next >
Text File  |  1998-06-30  |  3KB  |  99 lines

  1. /*
  2.  * @(#)SwingSetApplet.java    1.8 98/02/23
  3.  * 
  4.  * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  */
  20.  
  21. import com.sun.java.swing.*;
  22. import com.sun.java.swing.event.*;
  23. import com.sun.java.swing.text.*;
  24. import com.sun.java.swing.border.*;
  25. import java.awt.*;
  26. import java.awt.event.*;
  27. import java.util.*;
  28. import java.io.*;
  29.  
  30. import java.applet.*;
  31. import SwingSet;
  32.  
  33. public class SwingSetApplet extends JApplet {
  34.     JPanel panel;
  35.     
  36.     public void init() {
  37.  
  38.         String vers = System.getProperty("java.version");
  39.         final Applet thisApplet = this;
  40.  
  41.         if (vers.compareTo("1.1.2") < 0) {
  42.             System.out.println("!!!WARNING: Swing must be run with a " +
  43.                                "1.1.2 or higher version VM!!!");
  44.         }
  45.  
  46.     // Force SwingSet to come up in the Cross Platform L&F
  47.     try {
  48.         UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
  49.         // If you want the System L&F instead, comment out the above line and
  50.         // uncomment the following:
  51.         // UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
  52.     } catch (Exception exc) {
  53.         System.err.println("Error loading L&F: " + exc);
  54.     }
  55.  
  56.         panel = new JPanel();
  57.         getContentPane().add(panel,BorderLayout.CENTER);
  58.         panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
  59.  
  60.         JPanel progressPanel = SwingSet.createVerticalPanel(false);
  61.         panel.add(Box.createGlue());
  62.         panel.add(progressPanel);
  63.         panel.add(Box.createGlue());
  64.  
  65.         progressPanel.add(Box.createGlue());
  66.  
  67.         Dimension d = new Dimension(400, 20);
  68.         SwingSet.progressLabel = new JLabel("Loading, please wait...");
  69.         SwingSet.progressLabel.setMaximumSize(d);
  70.         progressPanel.add(SwingSet.progressLabel);
  71.         progressPanel.add(Box.createRigidArea(new Dimension(1,20)));
  72.  
  73.         SwingSet.progressBar = new JProgressBar();
  74.         SwingSet.progressBar.setMaximumSize(d);
  75.         SwingSet.progressBar.setMinimum(0);
  76.         SwingSet.progressBar.setMaximum(SwingSet.totalPanels);
  77.         SwingSet.progressBar.setValue(0);
  78.         progressPanel.add(SwingSet.progressBar);
  79.         progressPanel.add(Box.createGlue());
  80.         progressPanel.add(Box.createGlue());
  81.  
  82.         // show the panel
  83.         Rectangle ab = getContentPane().getBounds();
  84.         panel.setPreferredSize(new Dimension(ab.width,ab.height));
  85.         getContentPane().add(panel,BorderLayout.CENTER);
  86.         validate();
  87.         setVisible(true);
  88.  
  89.         SwingSet sw = new SwingSet(thisApplet);
  90.         getContentPane().remove(panel);
  91.         getContentPane().setLayout(new BorderLayout());
  92.         getContentPane().add(sw, BorderLayout.CENTER);
  93.         validate();
  94.         repaint();
  95.         sw.requestDefaultFocus();
  96.     }
  97. }
  98.  
  99.